package com.nbsaas.boot.project.rest.resource;

import com.nbsaas.boot.project.api.apis.ReceiptApi;
import com.nbsaas.boot.project.data.entity.Receipt;
import com.nbsaas.boot.project.api.domain.request.ReceiptRequest;
import com.nbsaas.boot.project.api.domain.response.ReceiptResponse;
import com.nbsaas.boot.project.api.domain.simple.ReceiptSimple;
import com.nbsaas.boot.project.rest.convert.ReceiptSimpleConvert;
import com.nbsaas.boot.project.rest.convert.ReceiptEntityConvert;
import com.nbsaas.boot.project.rest.convert.ReceiptResponseConvert;
import com.nbsaas.boot.project.data.repository.ReceiptRepository;

import java.io.Serializable;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
 *   收款单-业务接口实现
 */
@Transactional
@Service
public class ReceiptResource extends BaseResource<Receipt, ReceiptResponse, ReceiptSimple, ReceiptRequest> implements ReceiptApi {

    @Resource
    private ReceiptRepository receiptRepository;

    @Override
    public JpaRepositoryImplementation<Receipt, Serializable> getJpaRepository() {
        return receiptRepository;
    }

    @Override
    public Function<Receipt, ReceiptSimple> getConvertSimple() {
        return new ReceiptSimpleConvert();
    }

    @Override
    public Function<ReceiptRequest, Receipt> getConvertForm() {
        return new ReceiptEntityConvert();
    }

    @Override
    public Function<Receipt, ReceiptResponse> getConvertResponse() {
        return new ReceiptResponseConvert();
    }


}


